package com.atguigu.ssyx.home.controller;

import com.atguigu.ssyx.common.auth.AuthContextHolder;
import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.home.service.HomeService;
import com.atguigu.ssyx.model.search.SkuEs;

import com.atguigu.ssyx.vo.search.SkuEsQueryVo;
import com.mysql.cj.log.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * ClassName: HomeApiController
 * Package: com.atguigu.ssyx.home.controller
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-02
 * Time: 23:20
 */

@Api(tags = "首页接口")
@RestController
@RequestMapping("api/home/")
public class HomeApiController {

    @Autowired
    private HomeService homeService;

    //获取首页数据
    @ApiOperation("首页数据显示接口")
    @GetMapping("/index")
    public Result index(HttpServletRequest request){
        //这个TheadLocal是在不同的模块中
        Long userId = AuthContextHolder.getUserId();
        Map<String,Object> map = homeService.homeData(userId);
        return Result.ok(map);
    }


    //之前商品的上下架 是通过ES实现的 现在从ES中查询上架商品
    //查询是根据ES进行查询
    //根据分类 查询分类商品信息 直接写到search里面 免得远程调用了
//    @GetMapping("/{page}/{limit}")
//    public Result listSku(@PathVariable Long page,
//                          @PathVariable Long limit,
//                          SkuEsQueryVo skuEsQueryVo);



}
